//
//  HomeViewController.m
//  DoctorOnline
//
//  Created by leergou on 16/7/5.
//  Copyright © 2016年 WhiteHouse. All rights reserved.
//

#import "HomeViewController.h"
#import "HomeBannerView.h"
#import "HomeWeatherView.h"
#import "HomeChannelView.h"

@interface HomeViewController ()

/**
 *  weatherView
 */
@property (weak, nonatomic) UIView *weatherView;

/**
 *  bannerView
 */
@property (weak, nonatomic) UIView *bannerView;

/**
 *  yjImgView
 */
@property (weak, nonatomic) UIImageView *imageView;

/**
 * yjLabel
 */
@property (weak, nonatomic) UILabel *yjLabel;

/**
 *  channelView
 */
@property (weak, nonatomic) UIView *channelView;


@end

@implementation HomeViewController

- (void)viewDidLoad{
    [super viewDidLoad];
    
    [self setupUI];
    
}

#pragma mark - 1.设置界面
- (void)setupUI{
    
    // 设置导航栏
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBar.barTintColor = kThemeColor;
    
    self.title = @"导医通";
    
    // 1.天气 view
    HomeWeatherView *weatherView = [[HomeWeatherView alloc] init];
    
//    weatherView.backgroundColor = [UIColor greenColor];
    
    self.weatherView = weatherView;
    [self.view addSubview:weatherView];
    
    // 2.轮播器
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    HomeBannerView *bannerView = [[HomeBannerView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout];
    
    bannerView.backgroundColor = [UIColor redColor];
    
    bannerView.backgroundColor = [UIColor blueColor];
    
    self.bannerView = bannerView;
    [self.view addSubview:bannerView];
    
    // 3.名医通
    HomeChannelView *channelView = [[HomeChannelView alloc] init];
    
    channelView.backgroundColor = [UIColor redColor];
    
    self.channelView = channelView;
    [self.view addSubview:channelView];
    
    // 4.imageView
    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"yj"]];
    
    self.imageView = imageView;
    
    [self.view addSubview:imageView];
    
    // 5.yjLabel
    UILabel *yjLabel = [[UILabel alloc] init];
    yjLabel.text = @"名医通";
    yjLabel.font = [UIFont systemFontOfSize:20];
    
    self.yjLabel = yjLabel;
    [self.view addSubview:yjLabel];
}

#pragma mark - 2.设置约束
- (void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    
    [self setLayout];
}
- (void)setLayout{
    
    [self.weatherView makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.mas_topLayoutGuide);
        make.left.equalTo(self.view.left);
        make.right.equalTo(self.view.right);
        make.height.equalTo(80);
    }];
    
    
    [self.bannerView makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.weatherView.bottom);
        make.left.equalTo(self.view.left);
        make.right.equalTo(self.view.right);
        make.height.equalTo(207);
    }];
    
    [self.channelView makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.bannerView.bottom).offset(60);
        make.left.offset(0);
        make.right.offset(0);
        make.bottom.offset(0);
    }];
    
    
    [self.imageView makeConstraints:^(MASConstraintMaker *make) {
        
        make.height.equalTo(35);
        make.width.equalTo(12);
        make.left.equalTo(self.view).with.offset(20);
        make.top.equalTo(self.bannerView.bottom).with.offset(12);
    }];
    
    [self.yjLabel makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.imageView.right).with.offset(10);
        make.centerY.equalTo(self.imageView);
    }];
}


@end
